//
//  FQDMyMessageViewController.m
//  FakeQDaily
//
//  Created by mewxiv on 9/28/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDMyMessageViewController.h"
#import "FQDCommentMessageViewController.h"
#import "FQDPraiseMessageViewController.h"
#import "FQDSystemMessageViewController.h"
#import "FQDNavigationView.h"
#import "FQDTabbedPageView.h"
#import "FQDSegmentedControl.h"

#import "Masonry.h"

@interface FQDMyMessageViewController ()

@property (nonatomic, strong) FQDNavigationView *navView;
@property (nonatomic, strong) FQDTabbedPageView *pageView;

@end

@implementation FQDMyMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupNavigationView];
    [self setupTabViews];
}

- (void)setupNavigationView
{
    self.navView = [[FQDNavigationView alloc] init];
    self.navView.titleLabel.text = @"我的消息";
    self.navView.showBlurBg = YES;
    [self.navView.backButton addTarget:self action:@selector(popBack:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.navView];
    
    WeakSelf;
    [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.and.right.equalTo(weakSelf.view);
        make.height.equalTo(@64);
    }];
}

- (void)setupTabViews
{
    self.pageView = [[FQDTabbedPageView alloc] init];
    [self.view addSubview:self.pageView];
    
    NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    paragraphStyle.alignment = NSTextAlignmentCenter;
    NSDictionary *titleAttributes = @{
        NSFontAttributeName : FQDRegularFontWithSize(17.0f),
        NSForegroundColorAttributeName : RGB(136, 136, 136),
        NSParagraphStyleAttributeName : paragraphStyle,
    };
    NSDictionary *selectedTitleAttributes = @{
        NSFontAttributeName : FQDRegularFontWithSize(17.0f),
        NSForegroundColorAttributeName : [UIColor blackColor],
        NSParagraphStyleAttributeName : paragraphStyle,
    };
    self.pageView.segmentedControl.sectionTitleAttributes = titleAttributes;
    self.pageView.segmentedControl.selectedSectionTitleAttributes = selectedTitleAttributes;
    self.pageView.segmentedControl.selectIndicatorFixedWidthRatio = 0.8f;

    
    WeakSelf;
    [self.pageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.navView.mas_bottom);
        make.left.right.and.bottom.equalTo(weakSelf.view);
    }];
    
    FQDCommentMessageViewController *cmVC = [[FQDCommentMessageViewController alloc] init];
    [self addChildViewController:cmVC];
    [self.pageView addPage:cmVC.view withTitle:@"评论"];
    
    FQDPraiseMessageViewController *pmVC = [[FQDPraiseMessageViewController alloc] init];
    [self addChildViewController:pmVC];
    [self.pageView addPage:pmVC.view withTitle:@"点赞"];
    
    FQDSystemMessageViewController *smVC = [[FQDSystemMessageViewController alloc] init];
    [self addChildViewController:smVC];
    [self.pageView addPage:smVC.view withTitle:@"系统消息"];
}

#pragma mark - Event response
- (void)popBack:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

@end
